feat: add WebSocket call script for assistants and squads#3
Merged
Conversation
Adds the ability to initiate websocket calls directly from the gitops repo to test assistants and squads in real-time. Usage: bun run call:dev <assistant-name> bun run call:prod <assistant-name> bun run call:dev <squad-name> --squad Features: - Supports both assistants and squads - Works with nested paths (e.g., company-1/inbound-support) - Real-time audio I/O via microphone and speakers - Displays transcripts in terminal - Graceful shutdown with Ctrl+C VAP-11241 Co-Authored-By: Claude <noreply@anthropic.com>
VAP-11241 Co-Authored-By: Claude <noreply@anthropic.com>
- Changed CLI from `--squad` flag to explicit `-a <assistant>` and `-s <squad>` flags - Added microphone permission check at startup for macOS, Linux, and Windows - On macOS, attempts to trigger permission prompt before starting call - User can choose to continue if permission cannot be verified Usage: bun run call:dev -a my-assistant bun run call:prod -s my-squad VAP-11241 Co-Authored-By: Claude <noreply@anthropic.com>
VAP-11241 Co-Authored-By: Claude <noreply@anthropic.com>
dhruva-reddy
added a commit
that referenced
this pull request
May 2, 2026
## ELI5 **Problem.** The README documented "rollback" as `git revert + push`. That restores local *content* to a previous git state, but it does **not** restore a known *platform* snapshot — the subsequent push has all the same drift problems, so a "rollback" can clobber unrelated dashboard edits made since the bad deploy. There's also no engine- level record of *what was on the dashboard before the push*, so even in principle you can't put the platform back exactly the way it was. **What this fix does.** Before each PATCH, the engine writes both: - the *outgoing* payload (what we're about to send), AND - the *current platform* payload (what's there right now) to a per-push directory: ``` .vapi-state.<env>.snapshots/<ISO-timestamp>/<resource-type>/<id>.json ``` Snapshots are operator-local (gitignored) and recreated each push. A single timestamped directory pins one push run, so rollback can target an entire push, not individual PATCHes. `npm run rollback -- <env> --to <ISO-timestamp>` re-applies each `platform` payload from the snapshot as a PATCH. `--list` prints all available timestamps. **Outcome you'll notice.** Real undo. After a bad push, run `npm run rollback -- <env> --list` to see your snapshots, pick the one from before the bad push, and `--to <timestamp>` puts the dashboard back to that state. No more "I hope `git revert` does what I want." --- Real undo. Before each PATCH, write the *outgoing* (local) payload AND the *current platform* payload to a per-push directory. `npm run rollback -- <env> --to <ISO-timestamp>` re-applies each platform payload as a PATCH, restoring the dashboard to its state at the moment of the snapshot. Snapshots are operator-local state (.vapi-state.<env>.snapshots/), gitignored, and recreated on every push. Each push pins one timestamped directory so rollback can target an entire push, not individual PATCHes. Files: - src/snapshot.ts (NEW): writeSnapshot, listSnapshotTimestamps, loadSnapshot. Pins a single timestamp per push run (getRunSnapshotDir is idempotent within the process). Reuses sortedKeysReplacer so snapshot files have deterministic key order too. - src/rollback-cmd.ts (NEW): npm run rollback -- <env> --to <timestamp> re-applies each platform payload as a PATCH. --list prints available snapshots. - src/push.ts: writeSnapshot call after drift check passes. Costs one extra GET per resource (acceptable for the safety guarantee — follow- up: plumb drift's GET result through to avoid the duplicate fetch). Snapshot failures don't block the push. - package.json: rollback script. - .gitignore: .vapi-state.*.snapshots/ already covered. - AGENTS.md: document npm run rollback / --list. - tests/snapshot.test.ts: writeSnapshot creates the right path, multi-resource snapshots share a timestamp, listSnapshotTimestamps sorted, loadSnapshot round-trips. Closes improvements.md #3. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
dhruva-reddy
added a commit
that referenced
this pull request
May 2, 2026
## ELI5 **Problem.** The README documented "rollback" as `git revert + push`. That restores local *content* to a previous git state, but it does **not** restore a known *platform* snapshot — the subsequent push has all the same drift problems, so a "rollback" can clobber unrelated dashboard edits made since the bad deploy. There's also no engine- level record of *what was on the dashboard before the push*, so even in principle you can't put the platform back exactly the way it was. **What this fix does.** Before each PATCH, the engine writes both: - the *outgoing* payload (what we're about to send), AND - the *current platform* payload (what's there right now) to a per-push directory: ``` .vapi-state.<env>.snapshots/<ISO-timestamp>/<resource-type>/<id>.json ``` Snapshots are operator-local (gitignored) and recreated each push. A single timestamped directory pins one push run, so rollback can target an entire push, not individual PATCHes. `npm run rollback -- <env> --to <ISO-timestamp>` re-applies each `platform` payload from the snapshot as a PATCH. `--list` prints all available timestamps. **Outcome you'll notice.** Real undo. After a bad push, run `npm run rollback -- <env> --list` to see your snapshots, pick the one from before the bad push, and `--to <timestamp>` puts the dashboard back to that state. No more "I hope `git revert` does what I want." --- Real undo. Before each PATCH, write the *outgoing* (local) payload AND the *current platform* payload to a per-push directory. `npm run rollback -- <env> --to <ISO-timestamp>` re-applies each platform payload as a PATCH, restoring the dashboard to its state at the moment of the snapshot. Snapshots are operator-local state (.vapi-state.<env>.snapshots/), gitignored, and recreated on every push. Each push pins one timestamped directory so rollback can target an entire push, not individual PATCHes. Files: - src/snapshot.ts (NEW): writeSnapshot, listSnapshotTimestamps, loadSnapshot. Pins a single timestamp per push run (getRunSnapshotDir is idempotent within the process). Reuses sortedKeysReplacer so snapshot files have deterministic key order too. - src/rollback-cmd.ts (NEW): npm run rollback -- <env> --to <timestamp> re-applies each platform payload as a PATCH. --list prints available snapshots. - src/push.ts: writeSnapshot call after drift check passes. Costs one extra GET per resource (acceptable for the safety guarantee — follow- up: plumb drift's GET result through to avoid the duplicate fetch). Snapshot failures don't block the push. - package.json: rollback script. - .gitignore: .vapi-state.*.snapshots/ already covered. - AGENTS.md: document npm run rollback / --list. - tests/snapshot.test.ts: writeSnapshot creates the right path, multi-resource snapshots share a timestamp, listSnapshotTimestamps sorted, loadSnapshot round-trips. Closes improvements.md #3. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
dhruva-reddy
added a commit
that referenced
this pull request
May 2, 2026
## ELI5 **Problem.** The README documented "rollback" as `git revert + push`. That restores local *content* to a previous git state, but it does **not** restore a known *platform* snapshot — the subsequent push has all the same drift problems, so a "rollback" can clobber unrelated dashboard edits made since the bad deploy. There's also no engine- level record of *what was on the dashboard before the push*, so even in principle you can't put the platform back exactly the way it was. **What this fix does.** Before each PATCH, the engine writes both: - the *outgoing* payload (what we're about to send), AND - the *current platform* payload (what's there right now) to a per-push directory: ``` .vapi-state.<env>.snapshots/<ISO-timestamp>/<resource-type>/<id>.json ``` Snapshots are operator-local (gitignored) and recreated each push. A single timestamped directory pins one push run, so rollback can target an entire push, not individual PATCHes. `npm run rollback -- <env> --to <ISO-timestamp>` re-applies each `platform` payload from the snapshot as a PATCH. `--list` prints all available timestamps. **Outcome you'll notice.** Real undo. After a bad push, run `npm run rollback -- <env> --list` to see your snapshots, pick the one from before the bad push, and `--to <timestamp>` puts the dashboard back to that state. No more "I hope `git revert` does what I want." --- Real undo. Before each PATCH, write the *outgoing* (local) payload AND the *current platform* payload to a per-push directory. `npm run rollback -- <env> --to <ISO-timestamp>` re-applies each platform payload as a PATCH, restoring the dashboard to its state at the moment of the snapshot. Snapshots are operator-local state (.vapi-state.<env>.snapshots/), gitignored, and recreated on every push. Each push pins one timestamped directory so rollback can target an entire push, not individual PATCHes. Files: - src/snapshot.ts (NEW): writeSnapshot, listSnapshotTimestamps, loadSnapshot. Pins a single timestamp per push run (getRunSnapshotDir is idempotent within the process). Reuses sortedKeysReplacer so snapshot files have deterministic key order too. - src/rollback-cmd.ts (NEW): npm run rollback -- <env> --to <timestamp> re-applies each platform payload as a PATCH. --list prints available snapshots. - src/push.ts: writeSnapshot call after drift check passes. Costs one extra GET per resource (acceptable for the safety guarantee — follow- up: plumb drift's GET result through to avoid the duplicate fetch). Snapshot failures don't block the push. - package.json: rollback script. - .gitignore: .vapi-state.*.snapshots/ already covered. - AGENTS.md: document npm run rollback / --list. - tests/snapshot.test.ts: writeSnapshot creates the right path, multi-resource snapshots share a timestamp, listSnapshotTimestamps sorted, loadSnapshot round-trips. Closes improvements.md #3. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
dhruva-reddy
added a commit
that referenced
this pull request
May 5, 2026
## ELI5 **Problem.** The README documented "rollback" as `git revert + push`. That restores local *content* to a previous git state, but it does **not** restore a known *platform* snapshot — the subsequent push has all the same drift problems, so a "rollback" can clobber unrelated dashboard edits made since the bad deploy. There's also no engine- level record of *what was on the dashboard before the push*, so even in principle you can't put the platform back exactly the way it was. **What this fix does.** Before each PATCH, the engine writes both: - the *outgoing* payload (what we're about to send), AND - the *current platform* payload (what's there right now) to a per-push directory: ``` .vapi-state.<env>.snapshots/<ISO-timestamp>/<resource-type>/<id>.json ``` Snapshots are operator-local (gitignored) and recreated each push. A single timestamped directory pins one push run, so rollback can target an entire push, not individual PATCHes. `npm run rollback -- <env> --to <ISO-timestamp>` re-applies each `platform` payload from the snapshot as a PATCH. `--list` prints all available timestamps. **Outcome you'll notice.** Real undo. After a bad push, run `npm run rollback -- <env> --list` to see your snapshots, pick the one from before the bad push, and `--to <timestamp>` puts the dashboard back to that state. No more "I hope `git revert` does what I want." --- Real undo. Before each PATCH, write the *outgoing* (local) payload AND the *current platform* payload to a per-push directory. `npm run rollback -- <env> --to <ISO-timestamp>` re-applies each platform payload as a PATCH, restoring the dashboard to its state at the moment of the snapshot. Snapshots are operator-local state (.vapi-state.<env>.snapshots/), gitignored, and recreated on every push. Each push pins one timestamped directory so rollback can target an entire push, not individual PATCHes. Files: - src/snapshot.ts (NEW): writeSnapshot, listSnapshotTimestamps, loadSnapshot. Pins a single timestamp per push run (getRunSnapshotDir is idempotent within the process). Reuses sortedKeysReplacer so snapshot files have deterministic key order too. - src/rollback-cmd.ts (NEW): npm run rollback -- <env> --to <timestamp> re-applies each platform payload as a PATCH. --list prints available snapshots. - src/push.ts: writeSnapshot call after drift check passes. Costs one extra GET per resource (acceptable for the safety guarantee — follow- up: plumb drift's GET result through to avoid the duplicate fetch). Snapshot failures don't block the push. - package.json: rollback script. - .gitignore: .vapi-state.*.snapshots/ already covered. - AGENTS.md: document npm run rollback / --list. - tests/snapshot.test.ts: writeSnapshot creates the right path, multi-resource snapshots share a timestamp, listSnapshotTimestamps sorted, loadSnapshot round-trips. Closes improvements.md #3. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
dhruva-reddy
added a commit
that referenced
this pull request
May 5, 2026
## ELI5 **Problem.** The README documented "rollback" as `git revert + push`. That restores local *content* to a previous git state, but it does **not** restore a known *platform* snapshot — the subsequent push has all the same drift problems, so a "rollback" can clobber unrelated dashboard edits made since the bad deploy. There's also no engine- level record of *what was on the dashboard before the push*, so even in principle you can't put the platform back exactly the way it was. **What this fix does.** Before each PATCH, the engine writes both: - the *outgoing* payload (what we're about to send), AND - the *current platform* payload (what's there right now) to a per-push directory: ``` .vapi-state.<env>.snapshots/<ISO-timestamp>/<resource-type>/<id>.json ``` Snapshots are operator-local (gitignored) and recreated each push. A single timestamped directory pins one push run, so rollback can target an entire push, not individual PATCHes. `npm run rollback -- <env> --to <ISO-timestamp>` re-applies each `platform` payload from the snapshot as a PATCH. `--list` prints all available timestamps. **Outcome you'll notice.** Real undo. After a bad push, run `npm run rollback -- <env> --list` to see your snapshots, pick the one from before the bad push, and `--to <timestamp>` puts the dashboard back to that state. No more "I hope `git revert` does what I want." --- Real undo. Before each PATCH, write the *outgoing* (local) payload AND the *current platform* payload to a per-push directory. `npm run rollback -- <env> --to <ISO-timestamp>` re-applies each platform payload as a PATCH, restoring the dashboard to its state at the moment of the snapshot. Snapshots are operator-local state (.vapi-state.<env>.snapshots/), gitignored, and recreated on every push. Each push pins one timestamped directory so rollback can target an entire push, not individual PATCHes. Files: - src/snapshot.ts (NEW): writeSnapshot, listSnapshotTimestamps, loadSnapshot. Pins a single timestamp per push run (getRunSnapshotDir is idempotent within the process). Reuses sortedKeysReplacer so snapshot files have deterministic key order too. - src/rollback-cmd.ts (NEW): npm run rollback -- <env> --to <timestamp> re-applies each platform payload as a PATCH. --list prints available snapshots. - src/push.ts: writeSnapshot call after drift check passes. Costs one extra GET per resource (acceptable for the safety guarantee — follow- up: plumb drift's GET result through to avoid the duplicate fetch). Snapshot failures don't block the push. - package.json: rollback script. - .gitignore: .vapi-state.*.snapshots/ already covered. - AGENTS.md: document npm run rollback / --list. - tests/snapshot.test.ts: writeSnapshot creates the right path, multi-resource snapshots share a timestamp, listSnapshotTimestamps sorted, loadSnapshot round-trips. Closes improvements.md #3. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
-aand-sflagscompany-1/inbound-support)Usage
CLI Options
-a <name>-s <name>New Files
src/call.ts- Main entry point with WebSocket connection, audio handling, permission checks, and CLI parsingModified Files
package.json- Addedcall:devandcall:prodscripts, optionalmicandspeakerdependenciesREADME.md- Added comprehensive documentation for the WebSocket call featurePermission Check Flow
On startup, the script checks microphone permissions:
sox/recIf permission cannot be verified, the user is asked whether to continue.
Audio Dependencies
The audio dependencies (
mic,speaker) are marked as optional. The script works without them but will only show transcripts (no audio I/O). Users can install them with:npm install mic speaker # macOS may require: brew install soxTest plan
npm installto install dependenciesbun run call:dev -a <assistant-name>and verify:company-1/inbound-support)bun run call:dev -s <squad-name>-aand-sshows errorCloses VAP-11241
🤖 Generated with Claude Code